package com.sky.wsp.rabbitmq.topic.vo;

import com.sky.wsp.rabbitmq.topic.TopicMqConfig;
import com.sky.wsp.rabbitmq.topic.RabbitMqTopicProducer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription 在此输入描述
 * @date 2023/7/31
 */
@RestController
public class IDaaSController {

    @Resource
    private RabbitMqTopicProducer rabbitMqTopicProducer;

    @GetMapping("/send")
    public String testSendMQ(String username, String password) {
        UserPassword userPassword = new UserPassword();
        userPassword.setThirdId("thirdUserId");
        userPassword.setId("idaasUserId");
        userPassword.setTenantId(TopicMqConfig.ROUTING_KEY);
        userPassword.setUsername(username);
        userPassword.setMd5Password(password);

        IDaaSMessage<UserPassword> msg = new IDaaSMessage<>()
                .setMessageType(MessageTypeEnum.USER)
                .setTenantId(TopicMqConfig.ROUTING_KEY)
                .setEventType(EventTypeEnum.UPDATE)
                .setData(userPassword);
        // 通过MQ向三方应用发送消息
        rabbitMqTopicProducer.sendUserPassword(msg);
        return "send ok: " + username;
    }
}
